<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      body,
      ul {
        margin: 0;
        padding: 0;
      }
      body {
        background-image: url(../images/grid.png);
        /* background-repeat: no-repeat; */
      }
      svg {
        background-color: rgba(255, 0, 0, 0.1);
      }
    </style>
  </head>
  <body>
    <svg width="300" height="300" xmlns="http://www.w3.org/2000/svg">
      <rect
        id="rectangle"
        x="100"
        y="100"
        width="100"
        height="100"
        onclick="scaleRectanglr()"
      ></rect>
    </svg>

    <script src="./libs/gsap.min.js"></script>
    <script>
      function scaleRectanglr() {
        // 1. 补间动画(参数一支持数组 ["#rectangle","xxx"])
        // gsap.to("#rectangle", {
        //   scale: 0.5, //1 -> 0.5
        //   duration: 1,
        // });

        // gsap.from("#rectangle", {
        //   scale: 0.5, //0.5 - 1
        //   duration: 1,
        // });

        // gsap.fromTo(
        //   "#rectangle",
        //   {
        //     scale: 0.5, //0%
        //   },
        //   {
        //     scale: 1, //100%
        //     duration: 1,
        //   }
        // );

        // gsap.to("#rectangle", {
        //   scale: 0.5, //1 -> 0.5
        //   duration: 1,
        //   transformOrigin: "center", //动画的原点
        //   transformOrigin: "left",
        // });

        gsap.to("#rectangle", {
          scale: 0.5, //1 -> 0.5
          duration: 1,
          transformOrigin: "center", //动画的原点
          ease: "bounce.out",
        });
      }
    </script>
  </body>
</html>
